<template>
  <div class='tabs'>
    <span v-for="(item, index) in tabsData" :key="index" :class="{'color-blue':item.isActive,'tab':true}" @click="changeState(item)">
      {{item.label}}
    </span>
    <span v-for="(item, index) in btnsData" v-if="item.type=='btn'" :key="index" :class="item.class" @click="changeChooseAll(item)">
      {{item.label}}
    </span>
    <span v-else-if="item.type==='checked'" :class="item.class">
      <el-checkbox v-model="item.value" @change="changeChooseAll(item)">{{item.label}}</el-checkbox>
    </span>
  </div>
</template>
<script>
export default {
  props:['tabsData',"btnsData"],
  components: {},
  name: "",
  data() {
    return {};
  },
  methods: {
    changeState(item){
      this.tabsData.forEach(ele => {
        ele.isActive=false
      });
      this.$set(item,"isActive",true)
      if(item.click)item.click()
    },

    changeChooseAll(item){
      if(item.click)item.click(item)
    }
  },
  created() {}
};
</script>
<style scoped>
.tabs {
  margin-top: 20px;
  line-height: 39px;
  box-sizing: border-box;
  border-bottom: 1px solid #eee;
}
.tab{
  display: inline-block;
  width: 100px;
  text-align: center;
  cursor: pointer;
}
.tab.color-blue{
  color: #3f9ce2;
  border-bottom: 3px solid #3f9ce2;
}

.fr{
  text-align: center;
  font-size: 12px;
  margin-left: 10px;
  padding: 0 15px;
  line-height: 30px;
  cursor: pointer;
}
.fr.color-blue{
  background-color: #3f9ce2;
  color: #fff;
}
.fr.color-red{
  background-color: red;
  color: #fff;
}
</style>